﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBO;
using CommonLibrary;
using DBO.Economy;

namespace Serveur.DataAccess
{
    public class GameConstantsDataAccess : IGameConstantsDataAccess
    {
        public UnitStatistics GetStatisticByName(string name)
        {
            return AutoMapper.Mapper.Map<EF.UnitStatistics, DBO.UnitStatistics>(
                (from res in ContextHandler.Context.UnitTypeJeu
                   where res.Name == name
                   select res.Statistics).First());
        }

        public Resources GetResourceByName(string name)
        {
            return AutoMapper.Mapper.Map<EF.Resources, DBO.Economy.Resources>(
                (from res in ContextHandler.Context.UnitTypeJeu
                 where res.Name == name
                 select res.Price).First());
        }

        public List<Race> GetRaces()
        {
            return AutoMapper.Mapper.Map<List<EF.Race>, List<DBO.Race>>(
                (from res in ContextHandler.Context.RaceJeu
                 select res).ToList());
        }


        public Race GetRaceByName(string name)
        {
            return AutoMapper.Mapper.Map<EF.Race, DBO.Race>(
                (from res in ContextHandler.Context.RaceJeu
                 where res.Name == name
                 select res).First());
        }
    }
}
